<template>
	<view class="">
		<view class="px-2 border-bottom py-3">
			<view class="flex justify-between align-center">
				<view class="flex align-center">
					<image class="rounded-circle" @click="openuserspace" :src="item3.userpic" style="width: 90rpx; height: 90rpx" mode="aspectFill"></image>
					<view class="flex-column flex justify-between align-center px-2" style="height: 90rpx">
						<text class="flex-2 text-dark">{{ item3.nickName }}</text>
						<view class="text-white font-small px-1 flex align-center" :class="item3.sex === 1 ? 'bg-main' : 'bg-nan'" style="border-radius: 50rpx">
							<text v-if="item3.sex > 0" class="iconfont" :class="item3.sex === 1 ? 'icon-nv1' : 'icon-nan'"></text>
							<text v-else class="mr-1" style="font-size: 25rpx">??</text>
							{{ item3.age }}
						</view>
					</view>
				</view>

				<view class="">
					<view class="button text animated" hover-class="jello" v-if="item3.isFollow === 0" @click="follow(0)">关注</view>
					<view class="text bg-light text-dark px-2" v-else-if="item3.isFollow === 1" @click="follow(1)">已关注</view>
					<view class="text bg-hover-warning text-dark px-2" v-else-if="item3.isFollow === 2" @click="follow(2)">互关</view>
					<view class="text bg-hover-info text-dark px-2" style="color: aliceblue" v-else-if="item3.isFollow === 3" @click="follow(3)">回关</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { addFollow, delFollow } from '@/request/Api/post.js';
export default {
	props: {
		item3: {
			type: Object,
			default: () => ({})
		},
		index: {
			type: Number,
			default: 0
		}
	},
	data() {
		return {};
	},
	methods: {
		openuserspace() {
			uni.setStorageSync('image',this.item3.userpic)
			uni.navigateTo({
				url: '/pages/user-space/user-space?userId=' + this.item3.followId+"&nikeName="+this.item3.nickName+"&isFollow="+this.item3.isFollow
			});
		},
		follow(num) {
			let w;
			//关注
			if (num === 0) {
				w = 1;
				addFollow({
					followId: this.item3.followId
				}).then((res) => {
					this.emit(w);
				});
			}
			//取消关注
			if (num === 1) {
				w = 0;
				delFollow({
					followId: this.item3.followId
				}).then((res) => {
					this.emit(w);
				});
			}
			//取消关注
			if (num === 2) {
				w = 3;
				delFollow({
					followId: this.item3.followId
				}).then((res) => {
					this.emit(w);
				});
			}
			//关注
			if (num === 3) {
				w = 2;
				addFollow({
					followId: this.item3.followId
				}).then((res) => {
					this.emit(w);
				});
			}
		},
		emit(w) {
			uni.$emit('followOrdosupport', {
				type: 'follow',
				userId: this.item3.followId,
				num: w
			});
		}
	}
};
</script>

<style></style>
